package com.learn.exec;

/**
 * 创建两个线程，一个遍历100内偶数，另一个遍历奇数
 */
class ThreadForEven extends Thread{
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            if(i % 2 == 0){
                System.out.println(Thread.currentThread().getName() + ":" + i);
            }
        }
    }
}
class ThreadForOdd extends Thread{
    @Override
    public void run() {
        for (int i = 0; i < 100; i++) {
            if(i % 2 != 0){
                System.out.println(Thread.currentThread().getName() + ":" + i);
            }
        }
    }
}

public class ThreadDemo {
    public static void main(String[] args) {
        ThreadForEven t1 = new ThreadForEven();
        ThreadForOdd t2 = new ThreadForOdd();
        t1.start();
        t2.start();
    }
}
